package com.shop.controller;

import com.shop.common.SetMeta;
import com.shop.exception.ReportsException;
import com.shop.service.ReportsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ReportsController {

    @Autowired
    private ReportsService reportsService;

    @PreAuthorize("hasAuthority('148')")
    @GetMapping("reports/type/1")
    public SetMeta reportsOne() {
        SetMeta setMeta = new SetMeta();
        try {
            setMeta = reportsService.reportsOne();
        }catch (ReportsException e) {
            setMeta.setError(e.getMessage());
        }
        return setMeta;
    }
}
